//
//  ByViewHeaderSuccess.m
//  mijifen_ios
//
//  Created by mc on 2017/11/7.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByViewHeaderSuccess.h"

@implementation ByViewHeaderSuccess
{
    NSString    *_imgStr;
    NSString    *_title;
}
- (instancetype)initWith:(NSString *)img title:(NSString *)title{
    if (self = [super init]) {
        _imgStr = img;
        _title = title;
        [self createViews];
        self.backgroundColor = BY_TABLE_COLOR;
    }
    return self;
}

- (void)createViews{
    // 图片
    UIImageView *checkImg = [[UIImageView alloc] init];
    [self addSubview:checkImg];
    CGFloat width,height;
    if (@available(iOS 11.0,*)) {
        width = height = (SCREEN_HEIGHT - 50 * 2 - 10 - 34) / 2;
    }else{
        width = height = (SCREEN_HEIGHT - 50 * 2 - 10) / 2;
    }
    [checkImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(30));
        make.left.equalTo(@((SCREEN_WIDTH - width / 2) / 2));
        make.size.mas_equalTo(CGSizeMake(width / 2, height / 2));
    }];
    checkImg.image = [UIImage imageNamed:_imgStr];
    
    // title
    UILabel *grantLabel = [[UILabel alloc] init];
    [self addSubview:grantLabel];
    [grantLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(checkImg.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 30));
    }];
    grantLabel.textAlignment= NSTextAlignmentCenter;
    grantLabel.text = _title;
    grantLabel.font = B_FONT(24);
    
    // 中间虚线
    UIView *lineView = [[UIView alloc] init];
    [self addSubview:lineView];
//    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(@(10));
//        make.bottom.equalTo(@(0));
//        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 20, 1));
//    }];
    lineView.frame = CGRectMake(10, width, SCREEN_WIDTH - 20, 1);
    [CALayer drawDashLine:lineView lineLength:5 lineSpacing:5 lineColor:[UIColor lightGrayColor]];

}

@end
